Repeats a block of statements a specified number of times or until an Exit For statement runs. Uses a variable as a counter to track the number of times the loop runs. The counter can increment by any interval.
During playback, the counter variable is declared and the starting value is used as the variable value. After statements in the loop run, the counter increments and the current value is compared to the final counter value. If the current value is less than or equal to the final value, statements in the loop repeat. If the current value is greater than the final value, statements in the loop do not repeat and the script continues.
To loop through a block of statements once for each element in a group, use the For Each...Next statement.
Syntax
For Counter = Start To End [Step Increment]
[Statements]
Next
Arguments
| Argument | Description |
|---|---|
| Counter | Numeric variable used as a loop counter. |
| Start | Initial counter value. |
| End | End counter value. |
| Increment | Amount the counter increments each time the loop runs. Increments by 1 by default. For example, if the counter starts at 1 and increments by 2, the value is 3 the next time the loop repeats. |
| Statements | One or more statements that repeat. |
Keyword View notes
The counter variable and start and end values are displayed in the Information column.
Example
itemList = Window("BugReporter").ComboBox("comboboxType").Property("ListItems")
count = ArraySize(itemList, 1)
For x = 1 To count
curItemText = itemList(x)
Window("BugReporter").ComboBox("comboboxType").Item(curItemText).Select()
Next